package com.zzw.zim;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * System启动类

 * @author XiaoJie
 * @date 2025/05/12 10:21:10
 */
@SpringBootApplication(scanBasePackages = {"com.zzw"})
@EnableDiscoveryClient

@EnableFeignClients
@Slf4j
public class SystemApplicationStarter {
	public static void main (String[] args) throws UnknownHostException {
		ConfigurableApplicationContext context = SpringApplication.run(SystemApplicationStarter.class, args);
		Environment environment = context.getEnvironment();
//		 Iterator<String> iterator = context.getBeanFactory().getBeanNamesIterator();
//		 while (iterator.hasNext()) {
//		 	System.out.println(iterator.next());
//		 }
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = environment.getProperty("server.port");
		String path = environment.getProperty("server.servlet.context-path");


		if (!StringUtils.hasLength(path) || "/".equals(path)) {
			path = "";
		}
		log.info("\n----------------------------------------------------------\n\t" +
				"zzw-zim-system --->启动成功 URLs:\n\t" +
				"API文档网址: \t\t http://" + ip + ":" + port + path + "/doc.html\n" +
				"----------------------------------------------------------");
	}
}
